package name.huzhenbo.java.enums;

/**
 * while you cannot write an extensible enum type, you can
 * emulate it by writing an interface to go with a basic enum type that implements
 * the interface.
 */
public enum ExtendedOperation implements IOperation {
    EXP("^") {public double apply(double x, double y) {
        return Math.pow(x, y);
    }}, REMAINDER("%") {public double apply(double x, double y) {
        return x % y;
    }};

    private final String symbol;

    ExtendedOperation(String symbol) {
        this.symbol = symbol;
    }

    @Override
    public String toString() {
        return symbol;
    }
}
